﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Globalization;
using System.Windows.Forms;

namespace ClipboardTranslator
{
    public class Localization
    {
        static string path = Program.UserDataFolder + Path.DirectorySeparatorChar + "localization.ini";

        static IniDocument ini = null;

        static string section = CultureInfo.CurrentUICulture.EnglishName.ToLower().Split()[0];

        public static string Language { get { return section; } }

        public static string Localize(string key)
        {
            try
            {
                if (null == ini)
                {
                    if (!File.Exists(path))
                        File.Copy(Program.ApplicationFolder + Path.DirectorySeparatorChar + "localization.ini", path);
                    ini = new IniDocument(path);
                }

                if (!ini.HasKey(section, key))
                {
                    ini[section, key] = key;
                    ini.Save(path);
                }
                return ini[section, key];
            }
            catch
            {
                return key;
            }
        }
    }
}
